# Euclidean distance between two points
getDyadDist=function(posMatrix, ids){
  n=nrow(posMatrix)
  distMatrix = matrix(NA, nrow=n, ncol=n, dimnames=list(ids, ids))
  for(ii in 1:length(ids)){
    for(jj in 1:length(ids)){
      distMatrix[ii,jj] = sqrt( (posMatrix[ids[ii],1] - posMatrix[ids[jj],1])^2 
                                + (posMatrix[ids[ii],2] - posMatrix[ids[jj],2])^2 )
    }
  }
  distMatrix
}